<?php
namespace App\Http\Controllers\Api;

use Illuminate\Http\Request;
use App\Model\OperationLogs;
use App\Model\WishDefender;


class WishDefenderController extends BaseController
{
    protected $model = null;

    public function __construct(Request $request)
    {
        parent::__construct($request);
        $this->model = new WishDefender();
    }

    //擂主玩法设置单次抽奖消耗数量
    public function wishDefenderSetNeedNum(Request $request){
        $res = $this->model->wishDefenderSetNeedNum($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '擂主玩法设置单次抽奖消耗数量');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    /**
     * 擂主玩法设置全服/扣减擂主值
     */
    public function wishDefenderSetStartNum(Request $request){
        $res = $this->model->wishDefenderSetStartNum($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '擂主玩法设置全服/扣减擂主值');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //擂主玩法设置档位抽取次数
    public function wishDefenderSetDrawNum(Request $request){
        $res = $this->model->wishDefenderSetDrawNum($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '擂主玩法设置档位抽取次数');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //擂主玩法设置奖池开启/关闭
    public function wishDefenderSetPoolStatus(Request $request){
        $res = $this->model->wishDefenderSetPoolStatus($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '擂主玩法设置奖池开启/关闭');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //擂主玩法保存奖池配置
    public function wishDefenderSavePoolConfig(Request $request){
        $res = $this->model->wishDefenderSavePoolConfig($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '擂主玩法保存奖池配置');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //擂主玩法新增奖池
    public function wishDefenderAddPool(Request $request){

        $res = $this->model->wishDefenderAddPool($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '擂主玩法新增奖池');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //擂主玩法编辑奖池
    public function wishDefenderEditPool(Request $request){
        $res = $this->model->wishDefenderEditPool($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '擂主玩法编辑奖池');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //擂主玩法更新奖池缓存
    public function wishDefenderPoolReset(Request $request){
        $res = $this->model->wishDefenderPoolReset($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '擂主玩法更新奖池缓存');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //擂主玩法奖池列表
    public function wishDefenderPoolList(Request $request){
        $res = $this->model->wishDefenderPoolList($request);
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //擂主玩法配置信息
    public function wishDefenderConfig(Request $request){
        $res = $this->model->wishDefenderConfig($request);
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //擂主玩法奖池配置列表
    public function wishDefenderPoolConfigList(Request $request){
        $res = $this->model->wishDefenderPoolConfigList($request);
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //擂主玩法奖池配置剩余数量
    public function wishDefenderPoolConfigNum(Request $request){
        $res = $this->model->wishDefenderPoolConfigNum($request->all());
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //擂主玩法新增白名单
    public function wishDefenderAddWhite(Request $request){
        $res = $this->model->wishDefenderAddWhite($request->all(), $this->user);

        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '擂主玩法新增白名单');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //擂主玩法黑幕新增白名单
    public function wishDefenderAddWhite2(Request $request){

        $res = $this->model->wishDefenderAddWhite($request->all(), $this->user);
        $return= $this->toJson($res['code'], $res['data'], $res['msg']);

    }

    //擂主玩法删除白名单
    public function wishDefenderDelWhite(Request $request){
        $res = $this->model->wishDefenderDelWhite($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '擂主玩法删除白名单');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //擂主玩法白名单列表
    public function wishDefenderWhiteList(Request $request){
        $res = $this->model->wishDefenderWhiteList($request);
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //擂主玩法抽奖明细列表
    public function wishDefenderDrawList(Request $request){
        $res = $this->model->wishDefenderDrawList($request);
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //擂主游戏赠送礼物列表
    public function wishDefenderSendDrawList(Request $request){
        $res = $this->model->wishDefenderSendDrawList($request);
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //擂主玩法抽奖用户汇总数据
    public function wishDefenderUserStatistic(Request $request){
        $res = $this->model->wishDefenderUserStatistic($request);
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //擂主玩法抽奖用户汇总数据(同设备下)
    public function WishDefenderUserStatisticChild(Request $request){
        $res = $this->model->WishDefenderUserStatisticChild($request);
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //擂主玩法抽奖每日统计
    public function wishDefenderDayStatistic(Request $request){
        $res = $this->model->wishDefenderDayStatistic($request);
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //擂主玩法新增展示礼物
    public function wishDefenderAddGift(Request $request){
        $res = $this->model->wishDefenderAddGift($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '擂主玩法新增展示礼物');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //擂主玩法删除展示礼物
    public function wishDefenderDelGift(Request $request){
        $res = $this->model->wishDefenderDelGift($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '擂主玩法删除展示礼物');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //擂主玩法奖品列表
    public function wishDefenderGiftList(Request $request){
        return $this->toJson(self::SUCCESS, $this->model->wishDefenderGiftList($request));
    }

    //擂主玩法新增赠送展示礼物
    public function wishDefenderSendAddGift(Request $request){
        $res = $this->model->wishDefenderSendAddGift($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '擂主玩法新增展示礼物');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //擂主玩法删除赠送展示礼物
    public function wishDefenderSendDelGift(Request $request){
        $res = $this->model->wishDefenderSendDelGift($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '擂主玩法删除展示礼物');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //擂主玩法赠送奖品列表
    public function wishDefenderSendGiftList(Request $request){
        return $this->toJson(self::SUCCESS, $this->model->wishDefenderSendGiftList($request));
    }
    //擂主玩法新增个人池用户
    public function wishDefenderAddPoolUser(Request $request){
        $res = $this->model->wishDefenderAddPoolUser($request->all(), $this->user);
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '擂主玩法新增个人池用户');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //擂主玩法删除个人池用户
    public function wishDefenderDelPoolUser(Request $request){
        $res = $this->model->wishDefenderDelPoolUser($request->all(), $this->user);
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '擂主玩法删除个人池用户');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //擂主玩法查看个人奖池剩余数
    public function wishDefenderPoolSelfConfigNum(Request $request){
        $res = $this->model->wishDefenderPoolSelfConfigNum($request->all());

        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //擂主玩法个人池用户列表
    public function wishDefenderPoolUserList(Request $request){
        return $this->toJson(self::SUCCESS, $this->model->wishDefenderPoolUserList($request));
    }

    //擂主玩法奖池已配置礼物列表
    public function wishDefenderPoolGift(Request $request){
        return $this->toJson(self::SUCCESS, $this->model->wishDefenderPoolGift($request));
    }

    //擂主玩法新增奖池白名单
    public function wishDefenderAddPoolWhite(Request $request){
        $res = $this->model->wishDefenderAddPoolWhite($request->all(), $this->user);
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '擂主玩法新增奖池白名单');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);

    }
    //白名单奖池
    public function wishDefenderAddPoolWhite2(Request $request){
        $res = $this->model->wishDefenderAddPoolWhite($request->all(), $this->user);
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //擂主玩法删除奖池白名单
    public function wishDefenderDelPoolWhite(Request $request){
        $res = $this->model->wishDefenderDelPoolWhite($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '擂主玩法删除奖池白名单');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //擂主玩法取消投放奖池白名单
    public function wishDefenderCancelPoolWhite(Request $request){
        $res = $this->model->wishDefenderCancelPoolWhite($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '擂主玩法取消投放奖池白名单');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //擂主玩法奖池白名单列表
    public function wishDefenderPoolWhiteList(Request $request){
        $res = $this->model->wishDefenderPoolWhiteList($request, $this->user);
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //擂主玩法个人池奖池列表
    public function wishDefenderUserPoolList(Request $request){
        return $this->toJson(self::SUCCESS, $this->model->wishDefenderUserPoolList($request));
    }

    //擂主玩法更新进入个人池配置
    public function wishDefenderSetInUserPoolConfig(Request $request){
        $res = $this->model->wishDefenderSetInUserPoolConfig($request->all(), $this->user);
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '擂主玩法更新进入个人池配置');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //擂主玩法更新离开个人池配置
    public function wishDefenderSetOutUserPoolConfig(Request $request){
        $res = $this->model->wishDefenderSetOutUserPoolConfig($request->all(), $this->user);
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '擂主玩法更新离开个人池配置');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //擂主玩法个人池汇总数据
    public function wishDefenderUserPoolStat(Request $request){
        $res = $this->model->wishDefenderUserPoolStat($request);
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //擂主玩法奖池更新阀值
    public function wishDefenderSetUserPoolConfig(Request $request){
        $res = $this->model->wishDefenderSetUserPoolConfig($request->all(), $this->user);
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '擂主玩法奖池更新阀值');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }


}
